{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.7.1"
    },
    "toc": {
      "nav_menu": {},
      "number_sections": true,
      "sideBar": true,
      "skip_h1_title": false,
      "title_cell": "Table of Contents",
      "title_sidebar": "Contents",
      "toc_cell": false,
      "toc_position": {},
      "toc_section_display": true,
      "toc_window_display": false
    },
    "colab": {
      "name": "cnn-allconv.ipynb",
      "provenance": []
    },
    "widgets": {
      "application/vnd.jupyter.widget-state+json": {
        "2e7799992c7a4ff4b630688e9044e7ba": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_fcde82c39eaf4f999460ab34d6e36d4d",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_92e5582688c34604aff148cc175093df",
              "IPY_MODEL_c4b712ad3aae403d879a80461474ff4e"
            ]
          }
        },
        "fcde82c39eaf4f999460ab34d6e36d4d": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "92e5582688c34604aff148cc175093df": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_81ee0a2fc00b419194d8d809c6926dd7",
            "_dom_classes": [],
            "description": "",
            "_model_name": "FloatProgressModel",
            "bar_style": "success",
            "max": 1,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 1,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_7c839254d188412fae3f6d57a968f8cb"
          }
        },
        "c4b712ad3aae403d879a80461474ff4e": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_c26ce29bf66843f780db84c199fa6103",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": " 9920512/? [00:01&lt;00:00, 4965024.16it/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_5ce44ad50ce84c10bdc09a5cd9e9f0fe"
          }
        },
        "81ee0a2fc00b419194d8d809c6926dd7": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "initial",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "7c839254d188412fae3f6d57a968f8cb": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "c26ce29bf66843f780db84c199fa6103": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "5ce44ad50ce84c10bdc09a5cd9e9f0fe": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "4b10734727e54de2a42742659a2437f3": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_f1a327c5a3aa470280cba40534e3b874",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_64eeaaf124a04822a8f8dfa62e97d6b0",
              "IPY_MODEL_bdd67246307b4279ac8bc9d8912c1f9e"
            ]
          }
        },
        "f1a327c5a3aa470280cba40534e3b874": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "64eeaaf124a04822a8f8dfa62e97d6b0": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_fc371ca3906843d181cf09d3be2bd61a",
            "_dom_classes": [],
            "description": "",
            "_model_name": "FloatProgressModel",
            "bar_style": "success",
            "max": 1,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 1,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_0e2427eba175456db1c53f47e522606b"
          }
        },
        "bdd67246307b4279ac8bc9d8912c1f9e": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_dbcd7ea9cc614d2db7590c8d58b70e65",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": " 32768/? [00:00&lt;00:00, 53534.08it/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_79cf1bd426464a3a943437789ae15ac4"
          }
        },
        "fc371ca3906843d181cf09d3be2bd61a": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "initial",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "0e2427eba175456db1c53f47e522606b": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "dbcd7ea9cc614d2db7590c8d58b70e65": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "79cf1bd426464a3a943437789ae15ac4": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "a6d6de06c59f468ab5ece7501b8be1cb": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_371d3b82ed5f4dcbaf81cc21aafbe86c",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_f8fdd4089bce4e338327c91e5913351f",
              "IPY_MODEL_180a0cc799ac4f929c2c56f0ac77a349"
            ]
          }
        },
        "371d3b82ed5f4dcbaf81cc21aafbe86c": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "f8fdd4089bce4e338327c91e5913351f": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_fd974f6320474cb980d037df88850520",
            "_dom_classes": [],
            "description": "",
            "_model_name": "FloatProgressModel",
            "bar_style": "success",
            "max": 1,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 1,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_cc9981bfee514f679a6cad7594286cd4"
          }
        },
        "180a0cc799ac4f929c2c56f0ac77a349": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_029f97bc4b07429ca3a424c0c914ecba",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": " 1654784/? [00:00&lt;00:00, 3324733.52it/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_09281a020c6942948feaa1ebb66a09bc"
          }
        },
        "fd974f6320474cb980d037df88850520": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "initial",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "cc9981bfee514f679a6cad7594286cd4": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "029f97bc4b07429ca3a424c0c914ecba": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "09281a020c6942948feaa1ebb66a09bc": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "ae765a132561403eb69da4fcc32b2c23": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_7d934bec962f4f28859b8688296c451a",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_6e660960cc5a40c0a2b1a2646d8239e3",
              "IPY_MODEL_317624cde74e4faeba3942b712f90f88"
            ]
          }
        },
        "7d934bec962f4f28859b8688296c451a": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "6e660960cc5a40c0a2b1a2646d8239e3": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_6050b120723041838577f379c9d9dff0",
            "_dom_classes": [],
            "description": "",
            "_model_name": "FloatProgressModel",
            "bar_style": "success",
            "max": 1,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 1,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_6c646c05cffd4b39bc0bce593e9cc186"
          }
        },
        "317624cde74e4faeba3942b712f90f88": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_88199cd7eda7463ea4f09e1137f93401",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": " 8192/? [00:00&lt;00:00, 35279.69it/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_3207735fdf9c4d28a0e939b3ea9626fa"
          }
        },
        "6050b120723041838577f379c9d9dff0": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "initial",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "6c646c05cffd4b39bc0bce593e9cc186": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "88199cd7eda7463ea4f09e1137f93401": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "3207735fdf9c4d28a0e939b3ea9626fa": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        }
      }
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "UVSuwgzaaWYL",
        "colab_type": "text"
      },
      "source": [
        "Deep Learning Models -- A collection of various deep learning architectures, models, and tips for TensorFlow and PyTorch in Jupyter Notebooks.\n",
        "- Author: Sebastian Raschka\n",
        "- GitHub Repository: https://github.com/rasbt/deeplearning-models"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "EaDWwPO1ajzm",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "!pip install -q IPython\n",
        "!pip install -q ipykernel\n",
        "!pip install -q torch\n",
        "!pip install -q watermark\n",
        "!pip install -q matplotlib\n",
        "!pip install -q sklearn\n",
        "!pip install -q pandas\n",
        "!pip install -q pydot\n",
        "!pip install -q hiddenlayer\n",
        "!pip install -q graphviz"
      ],
      "execution_count": 1,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "AVCx3Hy8aWYN",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 121
        },
        "outputId": "cee5c362-0000-40cd-a225-0297077abbd6"
      },
      "source": [
        "%load_ext watermark\n",
        "%watermark -a 'Sebastian Raschka' -v -p torch"
      ],
      "execution_count": 2,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Sebastian Raschka \n",
            "\n",
            "CPython 3.6.9\n",
            "IPython 5.5.0\n",
            "\n",
            "torch 1.5.1+cu101\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "pyFp9dI_aWYT",
        "colab_type": "text"
      },
      "source": [
        "- Runs on CPU or GPU (if available)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "V86zOFl1aWYU",
        "colab_type": "text"
      },
      "source": [
        "# Model Zoo -- All-Convolutional Neural Network"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "bbdJNANaaWYV",
        "colab_type": "text"
      },
      "source": [
        "Simple convolutional neural network that uses stride=2 every 2nd convolutional layer, instead of max pooling, to reduce the feature maps. Loosely based on\n",
        "\n",
        "- Springenberg, Jost Tobias, Alexey Dosovitskiy, Thomas Brox, and Martin Riedmiller. \"Striving for simplicity: The all convolutional net.\" arXiv preprint arXiv:1412.6806 (2014)."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "0f1BGttcaWYV",
        "colab_type": "text"
      },
      "source": [
        "## Imports"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "C6IW8x86aWYW",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import time\n",
        "import numpy as np\n",
        "import torch\n",
        "import torch.nn.functional as F\n",
        "from torchvision import datasets\n",
        "from torchvision import transforms\n",
        "from torch.utils.data import DataLoader\n",
        "\n",
        "\n",
        "if torch.cuda.is_available():\n",
        "    torch.backends.cudnn.deterministic = True"
      ],
      "execution_count": 3,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "rcIAyfCGaWYa",
        "colab_type": "text"
      },
      "source": [
        "## Settings and Dataset"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "DAyslNMiaWYb",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 441,
          "referenced_widgets": [
            "2e7799992c7a4ff4b630688e9044e7ba",
            "fcde82c39eaf4f999460ab34d6e36d4d",
            "92e5582688c34604aff148cc175093df",
            "c4b712ad3aae403d879a80461474ff4e",
            "81ee0a2fc00b419194d8d809c6926dd7",
            "7c839254d188412fae3f6d57a968f8cb",
            "c26ce29bf66843f780db84c199fa6103",
            "5ce44ad50ce84c10bdc09a5cd9e9f0fe",
            "4b10734727e54de2a42742659a2437f3",
            "f1a327c5a3aa470280cba40534e3b874",
            "64eeaaf124a04822a8f8dfa62e97d6b0",
            "bdd67246307b4279ac8bc9d8912c1f9e",
            "fc371ca3906843d181cf09d3be2bd61a",
            "0e2427eba175456db1c53f47e522606b",
            "dbcd7ea9cc614d2db7590c8d58b70e65",
            "79cf1bd426464a3a943437789ae15ac4",
            "a6d6de06c59f468ab5ece7501b8be1cb",
            "371d3b82ed5f4dcbaf81cc21aafbe86c",
            "f8fdd4089bce4e338327c91e5913351f",
            "180a0cc799ac4f929c2c56f0ac77a349",
            "fd974f6320474cb980d037df88850520",
            "cc9981bfee514f679a6cad7594286cd4",
            "029f97bc4b07429ca3a424c0c914ecba",
            "09281a020c6942948feaa1ebb66a09bc",
            "ae765a132561403eb69da4fcc32b2c23",
            "7d934bec962f4f28859b8688296c451a",
            "6e660960cc5a40c0a2b1a2646d8239e3",
            "317624cde74e4faeba3942b712f90f88",
            "6050b120723041838577f379c9d9dff0",
            "6c646c05cffd4b39bc0bce593e9cc186",
            "88199cd7eda7463ea4f09e1137f93401",
            "3207735fdf9c4d28a0e939b3ea9626fa"
          ]
        },
        "outputId": "cd8b4a19-9350-4fd0-f514-d2489fa94f29"
      },
      "source": [
        "##########################\n",
        "### SETTINGS\n",
        "##########################\n",
        "\n",
        "# Device\n",
        "device = torch.device(\"cuda:1\" if torch.cuda.is_available() else \"cpu\")\n",
        "\n",
        "# Hyperparameters\n",
        "random_seed = 1\n",
        "learning_rate = 0.001\n",
        "num_epochs = 15\n",
        "batch_size = 256\n",
        "\n",
        "# Architecture\n",
        "num_classes = 10\n",
        "\n",
        "\n",
        "##########################\n",
        "### MNIST DATASET\n",
        "##########################\n",
        "\n",
        "# Note transforms.ToTensor() scales input images\n",
        "# to 0-1 range\n",
        "train_dataset = datasets.MNIST(root='data', \n",
        "                               train=True, \n",
        "                               transform=transforms.ToTensor(),\n",
        "                               download=True)\n",
        "\n",
        "test_dataset = datasets.MNIST(root='data', \n",
        "                              train=False, \n",
        "                              transform=transforms.ToTensor())\n",
        "\n",
        "\n",
        "train_loader = DataLoader(dataset=train_dataset, \n",
        "                          batch_size=batch_size, \n",
        "                          shuffle=True)\n",
        "\n",
        "test_loader = DataLoader(dataset=test_dataset, \n",
        "                         batch_size=batch_size, \n",
        "                         shuffle=False)\n",
        "\n",
        "# Checking the dataset\n",
        "for images, labels in train_loader:  \n",
        "    print('Image batch dimensions:', images.shape)\n",
        "    print('Image label dimensions:', labels.shape)\n",
        "    break"
      ],
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz to data/MNIST/raw/train-images-idx3-ubyte.gz\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "2e7799992c7a4ff4b630688e9044e7ba",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(FloatProgress(value=1.0, bar_style='info', max=1.0), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "Extracting data/MNIST/raw/train-images-idx3-ubyte.gz to data/MNIST/raw\n",
            "Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz to data/MNIST/raw/train-labels-idx1-ubyte.gz\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "4b10734727e54de2a42742659a2437f3",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(FloatProgress(value=1.0, bar_style='info', max=1.0), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "Extracting data/MNIST/raw/train-labels-idx1-ubyte.gz to data/MNIST/raw\n",
            "Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz to data/MNIST/raw/t10k-images-idx3-ubyte.gz\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "a6d6de06c59f468ab5ece7501b8be1cb",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(FloatProgress(value=1.0, bar_style='info', max=1.0), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "Extracting data/MNIST/raw/t10k-images-idx3-ubyte.gz to data/MNIST/raw\n",
            "Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz to data/MNIST/raw/t10k-labels-idx1-ubyte.gz\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "ae765a132561403eb69da4fcc32b2c23",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(FloatProgress(value=1.0, bar_style='info', max=1.0), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "Extracting data/MNIST/raw/t10k-labels-idx1-ubyte.gz to data/MNIST/raw\n",
            "Processing...\n",
            "Done!\n",
            "\n",
            "\n",
            "\n",
            "Image batch dimensions: torch.Size([256, 1, 28, 28])\n",
            "Image label dimensions: torch.Size([256])\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "/pytorch/torch/csrc/utils/tensor_numpy.cpp:141: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program.\n"
          ],
          "name": "stderr"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "esbQ3ynTaWYe",
        "colab_type": "text"
      },
      "source": [
        "## Model"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "SSJ_tSslaWYf",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "##########################\n",
        "### MODEL\n",
        "##########################\n",
        "\n",
        "\n",
        "class ConvNet(torch.nn.Module):\n",
        "\n",
        "    def __init__(self, num_classes):\n",
        "        super(ConvNet, self).__init__()\n",
        "        \n",
        "        self.num_classes = num_classes\n",
        "        # calculate same padding:\n",
        "        # (w - k + 2*p)/s + 1 = o\n",
        "        # => p = (s(o-1) - w + k)/2\n",
        "        \n",
        "        # 28x28x1 => 28x28x4\n",
        "        self.conv_1 = torch.nn.Conv2d(in_channels=1,\n",
        "                                      out_channels=4,\n",
        "                                      kernel_size=(3, 3),\n",
        "                                      stride=(1, 1),\n",
        "                                      padding=1) # (1(28-1) - 28 + 3) / 2 = 1\n",
        "        # 28x28x4 => 14x14x4\n",
        "        self.conv_2 = torch.nn.Conv2d(in_channels=4,\n",
        "                                      out_channels=4,\n",
        "                                      kernel_size=(3, 3),\n",
        "                                      stride=(2, 2),\n",
        "                                      padding=1)                             \n",
        "        # 14x14x4 => 14x14x8\n",
        "        self.conv_3 = torch.nn.Conv2d(in_channels=4,\n",
        "                                      out_channels=8,\n",
        "                                      kernel_size=(3, 3),\n",
        "                                      stride=(1, 1),\n",
        "                                      padding=1) # (1(14-1) - 14 + 3) / 2 = 1                 \n",
        "        # 14x14x8 => 7x7x8                             \n",
        "        self.conv_4 = torch.nn.Conv2d(in_channels=8,\n",
        "                                      out_channels=8,\n",
        "                                      kernel_size=(3, 3),\n",
        "                                      stride=(2, 2),\n",
        "                                      padding=1)      \n",
        "        \n",
        "        # 7x7x8 => 7x7x16                             \n",
        "        self.conv_5 = torch.nn.Conv2d(in_channels=8,\n",
        "                                      out_channels=16,\n",
        "                                      kernel_size=(3, 3),\n",
        "                                      stride=(1, 1),\n",
        "                                      padding=1) # (1(7-1) - 7 + 3) / 2 = 1          \n",
        "        # 7x7x16 => 4x4x16                             \n",
        "        self.conv_6 = torch.nn.Conv2d(in_channels=16,\n",
        "                                      out_channels=16,\n",
        "                                      kernel_size=(3, 3),\n",
        "                                      stride=(2, 2),\n",
        "                                      padding=1)      \n",
        "        \n",
        "        # 4x4x16 => 4x4xnum_classes                             \n",
        "        self.conv_7 = torch.nn.Conv2d(in_channels=16,\n",
        "                                      out_channels=self.num_classes,\n",
        "                                      kernel_size=(3, 3),\n",
        "                                      stride=(1, 1),\n",
        "                                      padding=1) # (1(7-1) - 7 + 3) / 2 = 1       \n",
        "\n",
        "\n",
        "        \n",
        "    def forward(self, x):\n",
        "        out = self.conv_1(x)\n",
        "        out = F.relu(out)\n",
        "        \n",
        "        out = self.conv_2(out)\n",
        "        out = F.relu(out)\n",
        "\n",
        "        out = self.conv_3(out)\n",
        "        out = F.relu(out)\n",
        "\n",
        "        out = self.conv_4(out)\n",
        "        out = F.relu(out)\n",
        "        \n",
        "        out = self.conv_5(out)\n",
        "        out = F.relu(out)\n",
        "        \n",
        "        out = self.conv_6(out)\n",
        "        out = F.relu(out)\n",
        "        \n",
        "        out = self.conv_7(out)\n",
        "        out = F.relu(out)\n",
        "        \n",
        "        logits = F.adaptive_avg_pool2d(out, 1)\n",
        "        # drop width\n",
        "        logits.squeeze_(-1)\n",
        "        # drop height\n",
        "        logits.squeeze_(-1)\n",
        "        probas = torch.softmax(logits, dim=1)\n",
        "        return logits, probas\n",
        "\n",
        "    \n",
        "torch.manual_seed(random_seed)\n",
        "model = ConvNet(num_classes=num_classes)\n",
        "\n",
        "model = model.to(device)\n",
        "\n",
        "optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate)  "
      ],
      "execution_count": 5,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "AaE6vPZ1ac2h",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 265
        },
        "outputId": "4677a22e-9a06-45b6-d55f-ffbed6b9cc13"
      },
      "source": [
        "import hiddenlayer as hl\n",
        "hl.build_graph(model, torch.zeros([128, 1, 28, 28]).to(device))"
      ],
      "execution_count": 6,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "/usr/local/lib/python3.6/dist-packages/torch/onnx/symbolic_opset9.py:514: UserWarning: ONNX export squeeze with negative axis -1 might cause the onnx model to be incorrect. Negative axis is not supported in ONNX. Axis is converted to 3 based on input shape at export time. Passing an tensor of different rank in execution will be incorrect.\n",
            "  \"Passing an tensor of different rank in execution will be incorrect.\")\n",
            "/usr/local/lib/python3.6/dist-packages/torch/onnx/symbolic_opset9.py:514: UserWarning: ONNX export squeeze with negative axis -1 might cause the onnx model to be incorrect. Negative axis is not supported in ONNX. Axis is converted to 2 based on input shape at export time. Passing an tensor of different rank in execution will be incorrect.\n",
            "  \"Passing an tensor of different rank in execution will be incorrect.\")\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<hiddenlayer.graph.Graph at 0x7f49bb2ee748>"
            ],
            "image/svg+xml": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Generated by graphviz version 2.40.1 (20161225.0304)\n -->\n<!-- Title: %3 Pages: 1 -->\n<svg width=\"678pt\" height=\"116pt\"\n viewBox=\"0.00 0.00 678.00 116.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(72 80)\">\n<title>%3</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"-72,36 -72,-80 606,-80 606,36 -72,36\"/>\n<!-- /outputs/29 -->\n<g id=\"node1\" class=\"node\">\n<title>/outputs/29</title>\n<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"269,-40 173,-40 173,-4 269,-4 269,-40\"/>\n<text text-anchor=\"start\" x=\"181\" y=\"-19\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">GlobalAveragePool</text>\n</g>\n<!-- 10983429736288617435 -->\n<g id=\"node3\" class=\"node\">\n<title>10983429736288617435</title>\n<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"412,-44 358,-44 358,0 412,0 412,-44\"/>\n<text text-anchor=\"start\" x=\"368\" y=\"-28\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Squeeze</text>\n<text text-anchor=\"start\" x=\"395\" y=\"-7\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x2</text>\n</g>\n<!-- /outputs/29&#45;&gt;10983429736288617435 -->\n<g id=\"edge1\" class=\"edge\">\n<title>/outputs/29&#45;&gt;10983429736288617435</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M269.3184,-22C294.3907,-22 324.5478,-22 347.7842,-22\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"347.9303,-25.5001 357.9302,-22 347.9302,-18.5001 347.9303,-25.5001\"/>\n<text text-anchor=\"middle\" x=\"313.5\" y=\"-25\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">128x10x1x1</text>\n</g>\n<!-- /outputs/32 -->\n<g id=\"node2\" class=\"node\">\n<title>/outputs/32</title>\n<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"534,-40 480,-40 480,-4 534,-4 534,-40\"/>\n<text text-anchor=\"start\" x=\"490\" y=\"-19\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Softmax</text>\n</g>\n<!-- 10983429736288617435&#45;&gt;/outputs/32 -->\n<g id=\"edge2\" class=\"edge\">\n<title>10983429736288617435&#45;&gt;/outputs/32</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M412.0758,-22C429.0553,-22 451.1767,-22 469.7924,-22\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"470,-25.5001 479.9999,-22 469.9999,-18.5001 470,-25.5001\"/>\n<text text-anchor=\"middle\" x=\"446\" y=\"-25\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">128x10</text>\n</g>\n<!-- 7820786384156773085 -->\n<g id=\"node4\" class=\"node\">\n<title>7820786384156773085</title>\n<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"84,-44 0,-44 0,0 84,0 84,-44\"/>\n<text text-anchor=\"start\" x=\"8\" y=\"-28\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv3x3 &gt; Relu</text>\n<text text-anchor=\"start\" x=\"69\" y=\"-7\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x7</text>\n</g>\n<!-- 7820786384156773085&#45;&gt;/outputs/29 -->\n<g id=\"edge3\" class=\"edge\">\n<title>7820786384156773085&#45;&gt;/outputs/29</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M84.4205,-22C107.7728,-22 137.103,-22 162.5915,-22\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"162.8823,-25.5001 172.8823,-22 162.8823,-18.5001 162.8823,-25.5001\"/>\n<text text-anchor=\"middle\" x=\"128.5\" y=\"-25\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">128x10x4x4</text>\n</g>\n</g>\n</svg>\n"
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 6
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "MvChBLxFaWYi",
        "colab_type": "text"
      },
      "source": [
        "## Training"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "SUd__24XaWYj",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "outputId": "33f4b679-61e1-4f8f-bed6-eec5a1694ddc"
      },
      "source": [
        "def compute_accuracy(model, data_loader):\n",
        "    correct_pred, num_examples = 0, 0\n",
        "    for features, targets in data_loader:\n",
        "        features = features.to(device)\n",
        "        targets = targets.to(device)\n",
        "        logits, probas = model(features)\n",
        "        _, predicted_labels = torch.max(probas, 1)\n",
        "        num_examples += targets.size(0)\n",
        "        correct_pred += (predicted_labels == targets).sum()\n",
        "    return correct_pred.float()/num_examples * 100\n",
        "    \n",
        "    \n",
        "start_time = time.time()\n",
        "for epoch in range(num_epochs):\n",
        "    model = model.train()\n",
        "    for batch_idx, (features, targets) in enumerate(train_loader):\n",
        "        \n",
        "        features = features.to(device)\n",
        "        targets = targets.to(device)\n",
        "\n",
        "        ### FORWARD AND BACK PROP\n",
        "        logits, probas = model(features)\n",
        "        cost = F.cross_entropy(logits, targets)\n",
        "        optimizer.zero_grad()\n",
        "        \n",
        "        cost.backward()\n",
        "        \n",
        "        ### UPDATE MODEL PARAMETERS\n",
        "        optimizer.step()\n",
        "        \n",
        "        ### LOGGING\n",
        "        if not batch_idx % 50:\n",
        "            print ('Epoch: %03d/%03d | Batch %03d/%03d | Cost: %.4f' \n",
        "                   %(epoch+1, num_epochs, batch_idx, \n",
        "                     len(train_loader), cost))\n",
        "    \n",
        "    model = model.eval()\n",
        "    print('Epoch: %03d/%03d training accuracy: %.2f%%' % (\n",
        "          epoch+1, num_epochs, \n",
        "          compute_accuracy(model, train_loader)))\n",
        "    \n",
        "    print('Time elapsed: %.2f min' % ((time.time() - start_time)/60))\n",
        "    \n",
        "print('Total Training Time: %.2f min' % ((time.time() - start_time)/60))"
      ],
      "execution_count": 7,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "\n",
            "Epoch: 001/015 | Batch 000/235 | Cost: 2.3051\n",
            "Epoch: 001/015 | Batch 050/235 | Cost: 2.2911\n",
            "Epoch: 001/015 | Batch 100/235 | Cost: 2.0713\n",
            "Epoch: 001/015 | Batch 150/235 | Cost: 1.5449\n",
            "Epoch: 001/015 | Batch 200/235 | Cost: 1.2272\n",
            "Epoch: 001/015 training accuracy: 73.14%\n",
            "Time elapsed: 0.41 min\n",
            "Epoch: 002/015 | Batch 000/235 | Cost: 1.0856\n",
            "Epoch: 002/015 | Batch 050/235 | Cost: 0.8327\n",
            "Epoch: 002/015 | Batch 100/235 | Cost: 0.6903\n",
            "Epoch: 002/015 | Batch 150/235 | Cost: 0.4573\n",
            "Epoch: 002/015 | Batch 200/235 | Cost: 0.5993\n",
            "Epoch: 002/015 training accuracy: 82.80%\n",
            "Time elapsed: 0.82 min\n",
            "Epoch: 003/015 | Batch 000/235 | Cost: 0.5988\n",
            "Epoch: 003/015 | Batch 050/235 | Cost: 0.4744\n",
            "Epoch: 003/015 | Batch 100/235 | Cost: 0.5527\n",
            "Epoch: 003/015 | Batch 150/235 | Cost: 0.5908\n",
            "Epoch: 003/015 | Batch 200/235 | Cost: 0.6320\n",
            "Epoch: 003/015 training accuracy: 84.42%\n",
            "Time elapsed: 1.23 min\n",
            "Epoch: 004/015 | Batch 000/235 | Cost: 0.5419\n",
            "Epoch: 004/015 | Batch 050/235 | Cost: 0.5285\n",
            "Epoch: 004/015 | Batch 100/235 | Cost: 0.3391\n",
            "Epoch: 004/015 | Batch 150/235 | Cost: 0.5635\n",
            "Epoch: 004/015 | Batch 200/235 | Cost: 0.3016\n",
            "Epoch: 004/015 training accuracy: 85.63%\n",
            "Time elapsed: 1.64 min\n",
            "Epoch: 005/015 | Batch 000/235 | Cost: 0.4622\n",
            "Epoch: 005/015 | Batch 050/235 | Cost: 0.4983\n",
            "Epoch: 005/015 | Batch 100/235 | Cost: 0.4859\n",
            "Epoch: 005/015 | Batch 150/235 | Cost: 0.3559\n",
            "Epoch: 005/015 | Batch 200/235 | Cost: 0.4443\n",
            "Epoch: 005/015 training accuracy: 86.12%\n",
            "Time elapsed: 2.05 min\n",
            "Epoch: 006/015 | Batch 000/235 | Cost: 0.4589\n",
            "Epoch: 006/015 | Batch 050/235 | Cost: 0.3866\n",
            "Epoch: 006/015 | Batch 100/235 | Cost: 0.4032\n",
            "Epoch: 006/015 | Batch 150/235 | Cost: 0.3736\n",
            "Epoch: 006/015 | Batch 200/235 | Cost: 0.2547\n",
            "Epoch: 006/015 training accuracy: 86.28%\n",
            "Time elapsed: 2.45 min\n",
            "Epoch: 007/015 | Batch 000/235 | Cost: 0.3954\n",
            "Epoch: 007/015 | Batch 050/235 | Cost: 0.3456\n",
            "Epoch: 007/015 | Batch 100/235 | Cost: 0.4622\n",
            "Epoch: 007/015 | Batch 150/235 | Cost: 0.3856\n",
            "Epoch: 007/015 | Batch 200/235 | Cost: 0.3274\n",
            "Epoch: 007/015 training accuracy: 86.93%\n",
            "Time elapsed: 2.86 min\n",
            "Epoch: 008/015 | Batch 000/235 | Cost: 0.3768\n",
            "Epoch: 008/015 | Batch 050/235 | Cost: 0.4407\n",
            "Epoch: 008/015 | Batch 100/235 | Cost: 0.3916\n",
            "Epoch: 008/015 | Batch 150/235 | Cost: 0.3756\n",
            "Epoch: 008/015 | Batch 200/235 | Cost: 0.3928\n",
            "Epoch: 008/015 training accuracy: 87.11%\n",
            "Time elapsed: 3.27 min\n",
            "Epoch: 009/015 | Batch 000/235 | Cost: 0.3697\n",
            "Epoch: 009/015 | Batch 050/235 | Cost: 0.3384\n",
            "Epoch: 009/015 | Batch 100/235 | Cost: 0.2915\n",
            "Epoch: 009/015 | Batch 150/235 | Cost: 0.3954\n",
            "Epoch: 009/015 | Batch 200/235 | Cost: 0.3258\n",
            "Epoch: 009/015 training accuracy: 87.43%\n",
            "Time elapsed: 3.68 min\n",
            "Epoch: 010/015 | Batch 000/235 | Cost: 0.4532\n",
            "Epoch: 010/015 | Batch 050/235 | Cost: 0.2722\n",
            "Epoch: 010/015 | Batch 100/235 | Cost: 0.3912\n",
            "Epoch: 010/015 | Batch 150/235 | Cost: 0.4258\n",
            "Epoch: 010/015 | Batch 200/235 | Cost: 0.3124\n",
            "Epoch: 010/015 training accuracy: 87.61%\n",
            "Time elapsed: 4.08 min\n",
            "Epoch: 011/015 | Batch 000/235 | Cost: 0.3304\n",
            "Epoch: 011/015 | Batch 050/235 | Cost: 0.4066\n",
            "Epoch: 011/015 | Batch 100/235 | Cost: 0.3537\n",
            "Epoch: 011/015 | Batch 150/235 | Cost: 0.2079\n",
            "Epoch: 011/015 | Batch 200/235 | Cost: 0.3632\n",
            "Epoch: 011/015 training accuracy: 87.42%\n",
            "Time elapsed: 4.50 min\n",
            "Epoch: 012/015 | Batch 000/235 | Cost: 0.4333\n",
            "Epoch: 012/015 | Batch 050/235 | Cost: 0.2662\n",
            "Epoch: 012/015 | Batch 100/235 | Cost: 0.3286\n",
            "Epoch: 012/015 | Batch 150/235 | Cost: 0.3609\n",
            "Epoch: 012/015 | Batch 200/235 | Cost: 0.3239\n",
            "Epoch: 012/015 training accuracy: 87.97%\n",
            "Time elapsed: 4.91 min\n",
            "Epoch: 013/015 | Batch 000/235 | Cost: 0.3066\n",
            "Epoch: 013/015 | Batch 050/235 | Cost: 0.4058\n",
            "Epoch: 013/015 | Batch 100/235 | Cost: 0.3318\n",
            "Epoch: 013/015 | Batch 150/235 | Cost: 0.2834\n",
            "Epoch: 013/015 | Batch 200/235 | Cost: 0.3052\n",
            "Epoch: 013/015 training accuracy: 88.12%\n",
            "Time elapsed: 5.31 min\n",
            "Epoch: 014/015 | Batch 000/235 | Cost: 0.3591\n",
            "Epoch: 014/015 | Batch 050/235 | Cost: 0.4121\n",
            "Epoch: 014/015 | Batch 100/235 | Cost: 0.2808\n",
            "Epoch: 014/015 | Batch 150/235 | Cost: 0.3257\n",
            "Epoch: 014/015 | Batch 200/235 | Cost: 0.3830\n",
            "Epoch: 014/015 training accuracy: 88.06%\n",
            "Time elapsed: 5.73 min\n",
            "Epoch: 015/015 | Batch 000/235 | Cost: 0.3500\n",
            "Epoch: 015/015 | Batch 050/235 | Cost: 0.3285\n",
            "Epoch: 015/015 | Batch 100/235 | Cost: 0.2623\n",
            "Epoch: 015/015 | Batch 150/235 | Cost: 0.2734\n",
            "Epoch: 015/015 | Batch 200/235 | Cost: 0.2648\n",
            "Epoch: 015/015 training accuracy: 88.38%\n",
            "Time elapsed: 6.13 min\n",
            "Total Training Time: 6.13 min\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Zguqg8GbaWYm",
        "colab_type": "text"
      },
      "source": [
        "## Evaluation"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "8SRoCfozaWYm",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "6e5ccc2d-30c7-4f1f-ac4c-b55159b325e4"
      },
      "source": [
        "print('Test accuracy: %.2f%%' % (compute_accuracy(model, test_loader)))"
      ],
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Test accuracy: 88.52%\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "qW2J9TwzaWYr",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 69
        },
        "outputId": "3f2ee893-0081-48cd-c790-de04583cc967"
      },
      "source": [
        "%watermark -iv"
      ],
      "execution_count": 9,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "torch 1.5.1+cu101\n",
            "numpy 1.18.5\n",
            "\n"
          ],
          "name": "stdout"
        }
      ]
    }
  ]
}